package com.cn.wanxi.service;

import com.cn.wanxi.dao.NewsDao;
import com.cn.wanxi.model.NewsModel;

public class NewsService {
    /**
     * 对网站首页的新闻信息封装
     *
     * @return
     */
    public NewsModel[] getNewsModels() {
        int length = NewsDao.CONTENTS.length;
        NewsModel[] newsModels = new NewsModel[length];
        for (int i = 0; i < length; i++) {
            NewsModel model = new NewsModel();
            model.setTitle(NewsDao.TITLES[i]);
            model.setContent(NewsDao.CONTENTS[i]);
            newsModels[i] = model;
        }
        return newsModels;
    }

    /**
     * 新闻页面的新闻信息
     *
     * @return
     */
    public NewsModel[] getNewsModelsForNewsPage() {
        int length = NewsDao.TITLES_FOR_NEWS_PAGE.length;
        NewsModel[] newsModels = new NewsModel[length];
        for (int i = 0; i < length; i++) {
            NewsModel model = new NewsModel();
            model.setTitle(NewsDao.TITLES_FOR_NEWS_PAGE[i]);
            model.setRedployTime(NewsDao.TIME_FOR_NEWS_PAGE[i]);
            newsModels[i] = model;
        }
        return newsModels;
    }
}
